package com.lb.trytest;

import org.apache.ibatis.io.Resources;

import java.io.IOException;
import java.io.Reader;
import java.math.BigDecimal;

import lombok.extern.slf4j.Slf4j;

/**
 * @version 1.0
 * @Author: Edward
 * @Date: 2021/5/7 9:16
 * @Description:
 */
@Slf4j
public class TryTest {
    public int getId(int i) throws Exception {
        int j = 0;
        try {
            j = 9 / i;
        } catch (Exception e) {
//            e.printStackTrace();
            log.error("计算失败：", e);
//            throw new Exception("计算失败");
        } /*finally {
            return 0;
        }*/

        return j;
    }

    /**
     * try 新语法糖
     */
    public void tryEL() throws IOException {
        try (Reader reader = Resources.getResourceAsReader("resource")){
            System.out.println(reader);
        }
    }

    public static void main(String[] args) throws Exception {
        TryTest t = new TryTest();
        System.out.println(t.getId(0));

        System.out.println("我还执行么");
//        String s = "1000.00";
//        System.out.println(Double.valueOf(s));
//        System.out.println(BigDecimal.valueOf(Double.valueOf(s)));
//
//        BigDecimal b1 = BigDecimal.valueOf(240);
//        BigDecimal b2 = BigDecimal.valueOf(239);
//        System.out.println(b2.compareTo(b1));


    }
}
